home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / perl5 / IPC::Open3.z / IPC::Open3
Encoding:
Text File  |  1998-10-30  |  2.7 KB  |  67 lines

  1.  
  2.  
  3.  
  4. IIIIPPPPCCCC::::::::OOOOppppeeeennnn3333((((3333))))                                                    IIIIPPPPCCCC::::::::OOOOppppeeeennnn3333((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      IPC::Open3, open3 - open a process for reading, writing, and error
  10.      handling
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.          $pid = open3(\*WTRFH, \*RDRFH, \*ERRFH,
  14.                          'some cmd and args', 'optarg', ...);
  15.  
  16.  
  17. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  18.      Extremely similar to _o_p_e_n_2(), _o_p_e_n_3() spawns the given $cmd and connects
  19.      RDRFH for reading, WTRFH for writing, and ERRFH for errors.  If ERRFH is
  20.      '', or the same as RDRFH, then STDOUT and STDERR of the child are on the
  21.      same file handle.  The WTRFH will have autoflush turned on.
  22.  
  23.      If WTRFH begins with "<&", then WTRFH will be closed in the parent, and
  24.      the child will read from it directly.  If RDRFH or ERRFH begins with
  25.      ">&", then the child will send output directly to that file handle.  In
  26.      both cases, there will be a _d_u_p(2) instead of a _p_i_p_e(2) made.
  27.  
  28.      If you try to read from the child's stdout writer and their stderr
  29.      writer, you'll have problems with blocking, which means you'll want to
  30.      use _s_e_l_e_c_t(), which means you'll have to use _s_y_s_r_e_a_d() instead of normal
  31.      stuff.
  32.  
  33.      _o_p_e_n_3() returns the process ID of the child process.  It doesn't return
  34.      on failure: it just raises an exception matching /^open3:/.
  35.  
  36. WWWWAAAARRRRNNNNIIIINNNNGGGG
  37.      It will not create these file handles for you.  You have to do this
  38.      yourself.  So don't pass it empty variables expecting them to get filled
  39.      in for you.
  40.  
  41.      Additionally, this is very dangerous as you may block forever.  It
  42.      assumes it's going to talk to something like bbbbcccc, both writing to it and
  43.      reading from it.  This is presumably safe because you "know" that
  44.      commands like bbbbcccc will read a line at a time and output a line at a time.
  45.      Programs like ssssoooorrrrtttt that read their entire input stream first, however,
  46.      are quite apt to cause deadlock.
  47.  
  48.      The big problem with this approach is that if you don't have control over
  49.      source code being run in the child process, you can't control what it
  50.      does with pipe buffering.  Thus you can't just open a pipe to cat -v and
  51.      continually read and write a line from it.
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.